<template>
	<el-upload
		ref="uploadPhoto"
	  class="avatar-uploader"
	  action=''
	  :show-file-list="false"
    :http-request="uploadAvatar"
	>
	  <img v-if="editData.avatar" :src="editData.avatar" class="avatar">
	  <i v-else class="el-icon-plus avatar-uploader-icon"></i>
	</el-upload>
</template>
<script>
export default {
  data() {
    return {
      editData: {}
    }
  },
  methods: {
    uploadAvatar(params) {
      var data = new FormData()
      data.append('file', params.file)
      service({
        url: '',
        method: 'post',
        data
      }).then(re => {
        if (re.code === 20000) {
          this.$message.success('上传成功')
          this.getList()
        }
      })
    }
  }
}
</script>
<style lang="scss">
  .avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 200px;
    height: 200px;
    line-height: 200px;
    text-align: center;
  }
  .avatar {
    width: 200px;
    height: 200px;
    display: block;
  }

</style>
